package com.teng.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.teng.entity.ModuleEntity;
import com.teng.entity.RoleEntity;
import com.teng.util.DBUtil;

public class ModuleDao {
	public List<ModuleEntity> list(String id)throws Exception{
		Connection connection=DBUtil.getConnection();
		try{
			String sql="select * from sys_menu where create_user_id=?";
			PreparedStatement ps=connection.prepareStatement(sql);
			ps.setString(1, id);
			ResultSet rs=ps.executeQuery();
			List<ModuleEntity> a=new ArrayList<>();
			while(rs.next()) {
				a.add(deposit(rs));
			}
			return a;
		}finally {
			connection.close();
		}
	}
	public ModuleEntity deposit(ResultSet rs) throws Exception{
		ModuleEntity me=new ModuleEntity();
		me.setCode(rs.getString("code"));
		me.setCreateTime(rs.getDate("create_time"));
		me.setCreateUserId(rs.getString("create_user_id"));
		me.setId(rs.getString("id"));
		me.setName(rs.getString("name"));
		me.setRemark(rs.getString("remark"));
		me.setFlag(rs.getInt("flag"));
		me.setIcon(rs.getString("icon"));
		me.setParentId(rs.getString("parent_id"));
		me.setUrl(rs.getString("url"));
		me.setShowOrder(rs.getString("show_order"));
		return me;
	}
}
